# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: site-packages\ntlm_auth\gss_channel_bindings.py
import struct


class GssChannelBindingsStruct(object):
    INITIATOR_ADDTYPE = "initiator_addtype"
    INITIATOR_ADDRESS_LENGTH = "initiator_address_length"
    ACCEPTOR_ADDRTYPE = "acceptor_addrtype"
    ACCEPTOR_ADDRESS_LENGTH = "acceptor_address_length"
    APPLICATION_DATA_LENGTH = "application_data_length"
    INITIATOR_ADDRESS = "initiator_address"
    ACCEPTOR_ADDRESS = "acceptor_address"
    APPLICATION_DATA = "application_data"

    def __init__(self):
        self.fields = {}
        self.fields[self.INITIATOR_ADDTYPE] = 0
        self.fields[self.INITIATOR_ADDRESS_LENGTH] = 0
        self.fields[self.ACCEPTOR_ADDRTYPE] = 0
        self.fields[self.ACCEPTOR_ADDRESS_LENGTH] = 0
        self.fields[self.APPLICATION_DATA_LENGTH] = 0
        self.fields[self.INITIATOR_ADDRESS] = b""
        self.fields[self.ACCEPTOR_ADDRESS] = b""
        self.fields[self.APPLICATION_DATA] = b""

    def __setitem__(self, key, value):
        self.fields[key] = value

    def get_data(self):
        self.fields[self.INITIATOR_ADDRESS_LENGTH] = len(
            self.fields[self.INITIATOR_ADDRESS]
        )
        self.fields[self.ACCEPTOR_ADDRESS_LENGTH] = len(
            self.fields[self.ACCEPTOR_ADDRESS]
        )
        self.fields[self.APPLICATION_DATA_LENGTH] = len(
            self.fields[self.APPLICATION_DATA]
        )
        data = (
            struct.pack("<L", self.fields[self.INITIATOR_ADDTYPE])
            + struct.pack("<L", self.fields[self.INITIATOR_ADDRESS_LENGTH])
            + self.fields[self.INITIATOR_ADDRESS]
            + struct.pack("<L", self.fields[self.ACCEPTOR_ADDRTYPE])
            + struct.pack("<L", self.fields[self.ACCEPTOR_ADDRESS_LENGTH])
            + self.fields[self.ACCEPTOR_ADDRESS]
            + struct.pack("<L", self.fields[self.APPLICATION_DATA_LENGTH])
            + self.fields[self.APPLICATION_DATA]
        )
        return data
